package com.ruoyi.web.controller.wx.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.vo.WxLoginRequest;
import com.ruoyi.web.controller.wx.service.IWxLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/wx")
public class WxLoginController {

    @Autowired
    private IWxLoginService wxLoginService;

    /**
     * 获取手机号
     * @param code
     * @return
     */
    @GetMapping("/getPhone")
    public AjaxResult getPhone(String code){
        Map<String, Object> map = wxLoginService.getPhoneNumber(code);
        return AjaxResult.success(map);
    }

    /**
     * 登录
     * @param wxLoginRequest
     * @return
     */
    @PostMapping("/login")
    public AjaxResult login(@RequestBody WxLoginRequest wxLoginRequest){
        Map<String, Object> map = wxLoginService.userLogin(wxLoginRequest);
        return AjaxResult.success(map);
    }

}
